<?php /*
	
*/ ?>
<?php include("system/config.inc.php");
$donotinclude = 1;
// IF admin is not logged in then it will redirect to the adminlogin page.
if(!isset($_SESSION['adminuserid']))
{
	header("location:index.php?msg=logfirst");
	die();
}

// UPDATE the record
$action=1;
if((isset($_REQUEST['a']) && trim($_REQUEST['a'])==2) && (!(isset($_REQUEST['Submit']) && trim($_REQUEST['Submit']) == "Submit")))
{
 	if(isset($_REQUEST['intid']) && trim($_REQUEST['intid'])!="")
 	{
		$screen_id =  mysql_real_escape_string($_REQUEST['intid']);
		$sql = "select * from tbltaxrates where intid =$screen_id";
		$result = $obj_db->select($sql);
		if(count($result)<=0) {
			echo " No Record Found!<br>";
			die();
		}
		
		if($result) {
			foreach($result as $row) {
				$rate = $row['vatrate'];	   
				$action=2;
			}
		}
		
		if(isset($_REQUEST['Submit']) && trim($_REQUEST['Submit']) == "Update")	{
			$vatrate = mysql_real_escape_string($_REQUEST['vatrate']);
			$sql_upd ="UPDATE tbltaxrates SET vatrate='$vatrate' WHERE intid=$screen_id";
			$result = $obj_db->edit($sql_upd);
			$action=1;
			header("location:tax.php?msg=edit");
			die();
		}
	}

}
?>
<?php include("inc/header.php");?>
<body>
<script language="javascript" src="js/tax.js"></script>
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="1" class="middlebackground">
  <tr>
    <td colspan="3" valign="top" align="center"><?php include(INC."top.inc.php");?></td>
  </tr>
  <tr>
    <td width="2%">&nbsp;</td>
    <td width="95%"><?php   
   if(isset($_REQUEST['script']))
	{
	if(trim($_REQUEST['script'])=='addtax' || trim($_REQUEST['script'])=='edittax')
	{
	?>
		<form action="" method="post" enctype="multipart/form-data" name="tax">
		
      <table width="70%" border="0" align="center" cellpadding="2" cellspacing="2" class="border">
        <tr class="bg1">
          <td colspan="5" align="center"><strong>Edit VAT Rate</strong></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td align="left">&nbsp;</td>
          <td>&nbsp;</td>
          <td align="right">(* All fields are Required)</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td width="2%">&nbsp;</td>
          <td width="30%" align="right" class="sltimg">*VAT Rate % figure<br />eg: for 15% insert 15 here</td>
          <td width="3%">:</td>
          <td width="56%" align="left"><label>
            <input name="vatrate" type="text" id="vatrate" value="<?php echo stripslashes($rate);?>" />
          </label></td>
          <td width="9%">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="5" align="left">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="5" align="center"><input name="Submit" type="submit" class="btn" id="Submit" value="Update" onClick="return check();"/></td>
        </tr>
        <tr>
          <td colspan="5" align="center">&nbsp;</td>
        </tr>
      </table></form>
    <?php
	}
}
else
{
?>
<br />
<br />
  <table width="75%" border="0" align="center" cellpadding="2" cellspacing="2" class="border">
      <tr class="bg1">
        <td align="left" colspan="2"><strong>VAT Rate</strong></td>
      </tr>
      <tr class="tblbg3">
        <td align="center" colspan="2"><strong>VAT Rate</strong></td> 
      </tr>
      <?php
   		$sql="SELECT * FROM tbltaxrates";
		$result=$obj_db->select($sql);
  		if($result)
		{
   		for($i=0;$i<count($result);$i++)
   		{
            $id=$result[$i]['intid'];
		?>
      <tr class="<?php echo ($i%2==0)?"Hrnormal":"Hralter"; ?>" onMouseOver="this.className='Hrhover';"  onmouseout="this.className='<?php echo ($i%2==0)?"Hrnormal":"Hralter"; ?>';">
        <td align="center"><?php echo stripslashes($result[$i]['vatrate']);?>%</td>
        <td align="center"><a class="link" Title="Click here to Edit" href="tax.php?script=edittax&amp;a=2&amp;intid=<?php echo $result[$i]['intid']; ?>"><img src="images/edit.bmp" border="0"/></a></td>
      </tr>
      <?php }}?>
    </table>
    <?php }?>
	</td>
    <td width="3%">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="3"><?php include("inc/bottom.php");?></td>
  </tr>
</table>


